﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ApplLogic.ApplClasses;

namespace TCPClient.UI.LogicForUserControls
{
    public class WorkersFilterHandler
    {
        private List<ApplWorker> m_AllWorkers = null;

        public WorkersFilterHandler()
        {
            initAllWorkersFromServer();
        }

        private void initAllWorkersFromServer()
        {
            m_AllWorkers = ScMainUserControlLogicManager.Instance.GetAllWorkers();
        }

        public List<string> GetAllWorkersFullNames()
        {
            List<string> workersFullNames = new List<string>();
            workersFullNames.Add("All Workers");
            workersFullNames.AddRange(m_AllWorkers.Select(applWorker => applWorker.PersonalDetails.FullName));
            return workersFullNames;
        }

        public string GetIdByName(string name)
        {
            foreach (var applWorker in m_AllWorkers)
            {
                if(applWorker.PersonalDetails.FullName == name)
                {
                    return applWorker.PersonalDetails.Id;
                }
            }
            return string.Empty;
        }
    }
}
